import { ipcRenderer } from 'electron'
// Custom APIs for renderer
const api = {
  insertDealerLevel: (dealerLevelName, isDividend) =>
    ipcRenderer.invoke('insert-dealer-level', dealerLevelName, isDividend),
  getAllDealerLevel: () => ipcRenderer.invoke('get-all-dealer-level'),
  deleteDealerLevel: (dealerLevelId) => ipcRenderer.invoke('deleteDealerLevel', dealerLevelId),
  editDealerLevel: (dealerLevelId, dealerLevelName, isDividend) =>
    ipcRenderer.invoke('editDealerLevel', dealerLevelId, dealerLevelName, isDividend),

  insertDealer: (
    parentDealerId,
    parentDealerName,
    dealerLevelId,
    dealerLevelName,
    dealerName,
    dealerAddress,
    dealerMobile,
    dealerRemark
  ) =>
    ipcRenderer.invoke(
      'insertDealer',
      parentDealerId,
      parentDealerName,
      dealerLevelId,
      dealerLevelName,
      dealerName,
      dealerAddress,
      dealerMobile,
      dealerRemark
    ),
  getDealerList: (pageSize, offset, dealerLevelId, dealerName) =>
    ipcRenderer.invoke('getDealerList', pageSize, offset, dealerLevelId, dealerName),
  getDealerListCount: (dealerId) => ipcRenderer.invoke('getDealerListCount', dealerId),
  updateDealerLevel: (dealerLevelId, dealerLevelName, dealerId) =>
    ipcRenderer.invoke('updateDealerLevel', dealerLevelId, dealerLevelName, dealerId),
  updateDealerRemark: (dealerRemark, dealerId) =>
    ipcRenderer.invoke('updateDealerRemark', dealerRemark, dealerId),
  deleteDealer: (dealerId, parentId, parentName) =>
    ipcRenderer.invoke('deleteDealer', dealerId, parentId, parentName),
  getDealerAll: (dealerLevelId, dealerName) =>
    ipcRenderer.invoke('getDealerAll', dealerLevelId, dealerName),
  updateDealer: (
    dealerId,
    parentDealerId,
    parentDealerName,
    dealerLevelId,
    dealerLevelName,
    dealerName,
    dealerAddress,
    dealerMobile,
    dealerRemark
  ) =>
    ipcRenderer.invoke(
      'updateDealer',
      dealerId,
      parentDealerId,
      parentDealerName,
      dealerLevelId,
      dealerLevelName,
      dealerName,
      dealerAddress,
      dealerMobile,
      dealerRemark
    ),

  insertDividend: (dividendName, isEnable, ratioList) =>
    ipcRenderer.invoke('insertDividend', dividendName, isEnable, ratioList),
  getDividendAll: () => ipcRenderer.invoke('getDividendAll'),
  getDividendByName: (dividendId, dividendName) =>
    ipcRenderer.invoke('getDividendByName', dividendId, dividendName),
  getDividendDetail: (dividendId) => ipcRenderer.invoke('getDividendDetail', dividendId),
  updateDividend: (
    dividendId,
    dividendName,
    isEnable,
    addRatioList,
    updateRatioList,
    delRatioList
  ) =>
    ipcRenderer.invoke(
      'updateDividend',
      dividendId,
      dividendName,
      isEnable,
      addRatioList,
      updateRatioList,
      delRatioList
    ),
  getDividendByIsEnable: (isEnable) => ipcRenderer.invoke('getDividendByIsEnable', isEnable),

  //业绩
  insertPerformance: (
    dealerId,
    dealerName,
    dealerParentId,
    dealerParentName,
    dealerLevelId,
    dealerLevelName,
    performanceDate,
    performanceMoney
  ) =>
    ipcRenderer.invoke(
      'insertPerformance',
      dealerId,
      dealerName,
      dealerParentId,
      dealerParentName,
      dealerLevelId,
      dealerLevelName,
      performanceDate,
      performanceMoney
    ),
  getPerformanceList: (pageSize, offset, startDate, endDate, dealerName, dealerLevelId) =>
    ipcRenderer.invoke(
      'getPerformanceList',
      pageSize,
      offset,
      startDate,
      endDate,
      dealerName,
      dealerLevelId
    ),
  getPerformanceExport: (startDate, endDate, dealerName, dealerLevelId) =>
    ipcRenderer.invoke('getPerformanceExport', startDate, endDate, dealerName, dealerLevelId),

  getDividendList: (pageSize, offset, startDate, endDate, dealerName, dealerLevelId) =>
    ipcRenderer.invoke(
      'getDividendList',
      pageSize,
      offset,
      startDate,
      endDate,
      dealerName,
      dealerLevelId
    ),
  getDealerPerformance: (dealerId, startDate, endDate) =>
    ipcRenderer.invoke('getDealerPerformance', dealerId, startDate, endDate),
  getDealerPersonPerformance: (dealerId, startDate, endDate) =>
    ipcRenderer.invoke('getDealerPersonPerformance', dealerId, startDate, endDate),

  //日志
  insertLogger: (msg) => ipcRenderer.invoke('insertLogger', msg),
  getLogger: (pageSize, offset) => ipcRenderer.invoke('getLogger', pageSize, offset),

  //业绩记录
  getPerformanceRecordByDealerForDate: (dealerId, startDate, endDate) =>
    ipcRenderer.invoke('getPerformanceRecordByDealerForDate', dealerId, startDate, endDate),

  //等级变更
  getDealerLevelChangeRecord: (dealerId) =>
    ipcRenderer.invoke('getDealerLevelChangeRecord', dealerId)
}

export default api
